$(function(){
	//初始化日期控件
  	$('#bt, #et').datetimepicker({
  		language: 'zh-CN',
	    format: 'yyyy-mm-dd',
	    autoclose: true,
	    minView: "month"
	});
	//加载数据
	loadDatas();

});

//加载玩家在线列表数据
function loadDatas(s){
	if(s=="search"){
		$("#page").val("");
	}
	//页码
	var page = $("#page").val();
	//一页显示的条数
	var pageSize = 40;
	//GameID
	var gameId = $("#gameId").val();
	//号码
	var phone = $("#phone").val();
	//时间
	var begin = $("#begin_time").val();
	var end = $("#end_time").val();
	//状态
	var state = $("#state").val();
	$.ajax({
		type: "post",
		data: {"page":page, "pageSize":pageSize, "begin":begin, "end":end, "gameId":gameId, "phone":phone, "state":state},
		url: "../../php/player/loadDuiHuanHuaFeiListData.php",
		beforeSend: function(){
			$("#load").css("display","block");
		},
		success: function(msg){
			$("#load").css("display","none");
			
			//表格数据
			var datas = msg.records;
			var html = "";
			if(datas.length == 0){
				html += "<tr><td colspan='9' align='center'>没查询到符合条件的数据~</td></tr>";
			}else{
				for(var i = 0; i<datas.length; i++){
					html += "<tr>";
					html += "<td><a style='color:blue' href='./playerInfo/playerDetailsInfo.php?gameId="+datas[i].gameId+"' title='查看玩家详情'>"+datas[i].gameId+"</a></td>";//玩家ID
					html += "<td><a style='color:blue' href='./playerInfo/playerDetailsInfo.php?gameId="+datas[i].gameId+"' title='查看玩家详情'>"+datas[i].nickName+"</a></td>";//用户昵称
					html += "<td>"+datas[i].time+"</td>";//时间
					html += "<td>"+datas[i].amount+"</td>";//数量
					html += "<td>"+datas[i].price+"</td>";//单价
					html += "<td>"+datas[i].totalRmb+"</td>";//总金额
					html += "<td>"+datas[i].phone+"</td>";//电话
					var state = datas[i].state;
					if(state == "0"){
						state = "充值中";
					}else if(state == "1"){
						state = "成功";
					}else{
						state = "失败";
					}
					html += "<td>"+state+"</td>";//状态
					html += "<td>"+datas[i].reason+"</td>";//失败原因
					html += "</tr>";
				}
			}
			$("#databody").html(html);

			//分页数据
			var pageInfo = msg.pageInfo;
			//总条数
			var allCount = pageInfo[0].count;
			$("#count").html(allCount);
			//总页数
			var allPage = Math.ceil(allCount/pageSize);
			if(allPage==0){
				allPage = 1;
			}
			//当前页码
			var now = pageInfo[0].page;
			
			$("#page").val(now);
			$("#nowPage").html(now);
			$("#allPage").html(allPage);
			$("#pageIpu").val("");
		}
	});
	
}

function findAll(s){
	$("#load").css("display","block");
	
	$("#reset").click();
	
	loadDatas(s);
}